/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.service;

import br.com.foxline.model.Charter;
import br.com.foxline.model.Part;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author roniere
 */
@Stateless
@LocalBean
public class PartService extends GenericService<Part>{

    public PartService() {
        super(Part.class);
    }

    public List<Part> getPartsByCharter(Charter charter){
        String sql = "Select p from Charter c JOIN c.parts p where c.id = :id";
        Query query = getEntityManager().createQuery(sql);
        query.setParameter("id", charter.getId());
        
        return query.getResultList();
    }
    
    
}
